package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.pagequery.NursingProjectPageQueryParam;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目相关接口")
@RequiredArgsConstructor
public class NursingProjectController {

    private final NursingProjectService nursingService;

    @GetMapping
    @ApiOperation(value = "分页查询护理项目", notes = "传入分页参数")
    public ResponseResult<PageResponse<NursingProjectVo>> page(@ApiParam(value = "分页参数", required = true)
                                                               NursingProjectPageQueryParam nursingProjectPageQueryParam){
        PageResponse<NursingProjectVo> nursingProjectVoPageResponse = nursingService.pageInfo(nursingProjectPageQueryParam);
        return ResponseResult.success(nursingProjectVoPageResponse);
    }

    @PostMapping
    @ApiOperation(value = "添加护理项目", notes = "传入护理项目对象")
    public ResponseResult add(@ApiParam(value = "护理项目对象", required = true)
                                  @RequestBody NursingProjectDto nursingProjectDto){
        nursingService.addNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理项目", notes = "传入id")
    public ResponseResult<NursingProjectVo> getById(@ApiParam(value = "id", required = true)
                                                       @PathVariable Long id){
        NursingProjectVo nursingProjectVo = nursingService.getById(id);
        return ResponseResult.success(nursingProjectVo);
    }

    @PutMapping
    @ApiOperation(value = "修改护理项目", notes = "传入护理项目对象")
    public ResponseResult update(@ApiParam(value = "护理项目对象", required = true)
                                 @RequestBody NursingProjectDto nursingProjectDto){
        nursingService.updateNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }
/*
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "启用禁用护理项目", notes = "传入状态参数")
    public ResponseResult updateStatus(@ApiParam(value = "状态参数", required = true)
                                       @PathVariable Long id,@PathVariable Integer status){
        nursingService.updateNursingProjectStatus(id,status);
        return ResponseResult.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理项目", notes = "传入id")
    public ResponseResult delete(@ApiParam(value = "id", required = true)
                                 @PathVariable Long id){
        nursingService.deleteById(id);
        return ResponseResult.success();
    }
    @GetMapping("/all")
    @ApiOperation(value = "查询护理项目列表", notes = "无参数")
    public ResponseResult<List<NursingProjectVo>> getAll(){
        List<NursingProjectVo> nursingProjectVoList = nursingService.getAll();
        return ResponseResult.success(nursingProjectVoList);
    }*/
}
